package com.example.administrator.himalaya.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;

import com.example.administrator.himalaya.R;

public class SettingActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener, View.OnClickListener {

    private Switch mASwitch;
    private LinearLayout mLayout;
    private ImageView mBack;
    private TextView mHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        mASwitch = (Switch) findViewById(R.id.swh_status);
        mASwitch.setOnCheckedChangeListener(this);
        mLayout = (LinearLayout) findViewById(R.id.layout_linear);
        mBack = (ImageView) findViewById(R.id.back);
        mBack.setOnClickListener(this);
        mHelper = (TextView) findViewById(R.id.helper);
        mHelper.setOnClickListener(this);
    }

    @Override
    public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
        if (compoundButton.isChecked()) {
//            Toast.makeText(this, "开关:ON", Toast.LENGTH_SHORT).show();
            mLayout.setVisibility(View.VISIBLE);
        } else {
//            Toast.makeText(this, "开关:OFF", Toast.LENGTH_SHORT).show();
            mLayout.setVisibility(View.GONE);
        }

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.helper:
                Intent intent = new Intent(this,HelperActivity.class);
                startActivity(intent);
        }
    }
}
